using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class AppointmentScript : MonoBehaviour
{
    // Start is called before the first frame update   ：：：
    string[,] conversation = {
        {"恭迎主上","看主上似是有烦忧之事","眉头都皱起来了","在臣妾这里就不要想那些不开心的事啦，主上不开心，臣妾也会难过的","为了让主上开心，臣妾讲个笑话吧。","从前有个大老虎，碰上一只小白兔，啊呜，大老虎吃掉了小白兔。" },
        {"臣妾最喜欢一首诗了","坐酌泠泠水，看煎瑟瑟尘。","无由持一碗，寄与爱茶人。","主上与臣妾一样都是爱茶之人。","听说主上那里有来自江南的新茶，主上下次来给我带点呗","我们再一起看茶烟袅袅，听落棋声声。" },
        {"弱水三千只取一瓢饮，娇梅万朵独摘一枝怜。","臣妾想做主上那唯一的一瓢水、一枝梅。","青丝变白发","朝阳又夕下","三餐四季","煮茶赏花" },
        {"咳咳咳，臣妾是不......时日无多了......","大夫说，只有天山雪莲才能医治臣妾的病，可是天山雪莲是何等珍贵之物，到哪去弄来，臣妾怕是只能等死了吧......","(面色憔悴)......","药好苦，但是有主上陪着，心里很甜。","主上会经常来看臣妾的吗？","在生病的这些日子，有主上陪着我臣妾，臣妾真的好幸福。" },
        {"想为主上做一幅画","以心为笔","以情为墨","以爱你为内容","以余生为落笔","余生可待。" },
        {"有一种安排叫做缘，","冥冥之中，自有天意。","有一张网叫做情，","情网恢恢，疏而不漏。","有一种爱叫思念，","四处弥漫，牵牵绊绊。" }
    };
    //随机数，选男宠
    int number;
    //随机数，选对话组合
    int order;
    //随机数,属性选择
    int att1;
    int att2;
    //随机数，属性增加数值
    int attadd1;
    int attadd2;
    //属性地址
    string[] c = { "Leveling/魅力+", "Leveling/容貌+", "Leveling/情缘+", "Leveling/好感+" };


    //男宠and女王
    public Image handsomeManImg;
    public Image roleImg;
    //对话
    public Text nameTag;
    public Text dialogueText;

    //结算
    public GameObject endPanel;
    //public Image Back1;//返回
    public Image AttributeIncrease1;//奖励1图
    public Image AttributeIncrease2;//奖励2图
    public Text AttributeAddValue1;//奖励1值
    public Text AttributeAddValue2;//奖励2值

    private void Awake()
    {
        number = Random.Range(0, 6);//此次召唤的男宠序号
        order = Random.Range(0, 6);//此次对白序号
        att1 = Random.Range(0, 4);
        att2 = Random.Range(0, 4);
        attadd1 = Random.Range(10, 50);
        attadd2 = Random.Range(10, 50);
        while (att1 == att2)
        {
            att1 = Random.Range(0, 4);
        }

    }
    void Start()
    {
        handsomeManImg.sprite = Resources.Load<Sprite>(VariableDocument.GetInstance.allHandsomeMen[number,1]);
        roleImg.sprite = Resources.Load<Sprite>(VariableDocument.GetInstance.roleImgAdress[VariableDocument.GetInstance.clothNum]);
        nameTag.text = VariableDocument.GetInstance.allHandsomeMen[number,0];
        dialogueText.text = conversation[order, 0];
    }

    int i = 1;//对白第几句
    int a = 0;//设定对白是否完成的状态
    // Update is called once per frame
    void Update()
    {
        if (Input.mousePosition.y < 660)
        {
            if (i < 6)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    dialogueText.GetComponent<Text>().text = conversation[order, i];
                    i++;
                }

            }
            else
            {
                if (Input.GetMouseButtonDown(0))
                {
                    if (a == 0)
                    {
                        AttributeIncrease1.sprite = Resources.Load<Sprite>(c[att1]);
                        AttributeIncrease2.sprite = Resources.Load<Sprite>(c[att2]);
                        AttributeAddValue1.text = "" + attadd1;
                        AttributeAddValue2.text = "" + attadd2;
                        VariableDocument.GetInstance.attributes[att1] += attadd1;
                        VariableDocument.GetInstance.attributes[att2] += attadd2;
                        a = 1;
                    }
                    endPanel.SetActive(true);

                }

            }
        }
    }
}
